using UnityEngine;
using UnityEngine.UI;
using TMPro;

[AddComponentMenu("PVold/SimpleLocalisation")]
public class SimpleLocalisation : MonoBehaviour
{
	public static bool english;

	[TextArea(2, 10)]
	public string russian;

	[TextArea(2, 10)]
	public string eng;

	private Text uiText;
    private TextMeshProUGUI tmp;

	public static bool isRussia()
	{
		return !english && (Application.systemLanguage == SystemLanguage.Russian || Application.systemLanguage == SystemLanguage.Ukrainian || Application.systemLanguage == SystemLanguage.Belarusian);
	}

	private void Awake()
	{
		uiText = base.gameObject.GetComponent<Text>();
        if (uiText) uiText.text = eng;
        else
        {
            tmp = gameObject.GetComponent<TextMeshProUGUI>();
            tmp.text = eng;
        }
		//if (isRussia() && uiText.text.IndexOf(russian) == -1)
		//{
		//	uiText.text = russian;
		//}
		//else if (!isRussia() && uiText.text != russian && uiText.text.IndexOf(russian) != -1)
		//{
		//	uiText.text = uiText.text.Replace(russian, eng);
		//}
		//else if (!isRussia())
		//{
		//	uiText.text = eng;
		//}
		UnityEngine.Object.Destroy(this);
	}

	private void OnEnable()
	{
		Awake();
	}
}
